package com.lightChat.service.impl;

import com.lightChat.entity.Users;
import com.lightChat.mapper.UsersMapper;
import com.lightChat.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sxt
 * @create 2019-11-06 21:48
 */

@Service
public class UserServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public List<Users> queryAllUsers() {
        List<Users> users = usersMapper.selectAllUsers();
        return users;
    }

    @Override
    public void register(Users users) {
        usersMapper.addUser(users);
    }

    @Override
    public Users login(Users users) {
        Users resultUser = usersMapper.selectUserByUsernameAndPassword(users);
        return resultUser;
    }

    @Override
    public Users queryUserByUsername(String username) {
        Users users = usersMapper.selectUserByUsername(username);
        return users;
    }
}
